/**
 * <copyright>
 * </copyright>
 *

 */
package hu.bme.mit.androtext.gui.androGui.impl;

import hu.bme.mit.androtext.gui.androGui.AndroGuiPackage;
import hu.bme.mit.androtext.gui.androGui.EditTextPreference;
import hu.bme.mit.androtext.gui.androGui.PreferenceDefaultValueAttribute;
import hu.bme.mit.androtext.gui.androGui.PreferenceDialogTitleAttribute;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Edit Text Preference</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link hu.bme.mit.androtext.gui.androGui.impl.EditTextPreferenceImpl#getDialogTitle <em>Dialog Title</em>}</li>
 *   <li>{@link hu.bme.mit.androtext.gui.androGui.impl.EditTextPreferenceImpl#getDefaultValue <em>Default Value</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class EditTextPreferenceImpl extends PreferenceImpl implements EditTextPreference
{
  /**
   * The cached value of the '{@link #getDialogTitle() <em>Dialog Title</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDialogTitle()
   * @generated
   * @ordered
   */
  protected PreferenceDialogTitleAttribute dialogTitle;

  /**
   * The cached value of the '{@link #getDefaultValue() <em>Default Value</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDefaultValue()
   * @generated
   * @ordered
   */
  protected PreferenceDefaultValueAttribute defaultValue;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected EditTextPreferenceImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return AndroGuiPackage.Literals.EDIT_TEXT_PREFERENCE;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public PreferenceDialogTitleAttribute getDialogTitle()
  {
    return dialogTitle;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetDialogTitle(PreferenceDialogTitleAttribute newDialogTitle, NotificationChain msgs)
  {
    PreferenceDialogTitleAttribute oldDialogTitle = dialogTitle;
    dialogTitle = newDialogTitle;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AndroGuiPackage.EDIT_TEXT_PREFERENCE__DIALOG_TITLE, oldDialogTitle, newDialogTitle);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setDialogTitle(PreferenceDialogTitleAttribute newDialogTitle)
  {
    if (newDialogTitle != dialogTitle)
    {
      NotificationChain msgs = null;
      if (dialogTitle != null)
        msgs = ((InternalEObject)dialogTitle).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - AndroGuiPackage.EDIT_TEXT_PREFERENCE__DIALOG_TITLE, null, msgs);
      if (newDialogTitle != null)
        msgs = ((InternalEObject)newDialogTitle).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - AndroGuiPackage.EDIT_TEXT_PREFERENCE__DIALOG_TITLE, null, msgs);
      msgs = basicSetDialogTitle(newDialogTitle, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, AndroGuiPackage.EDIT_TEXT_PREFERENCE__DIALOG_TITLE, newDialogTitle, newDialogTitle));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public PreferenceDefaultValueAttribute getDefaultValue()
  {
    return defaultValue;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetDefaultValue(PreferenceDefaultValueAttribute newDefaultValue, NotificationChain msgs)
  {
    PreferenceDefaultValueAttribute oldDefaultValue = defaultValue;
    defaultValue = newDefaultValue;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AndroGuiPackage.EDIT_TEXT_PREFERENCE__DEFAULT_VALUE, oldDefaultValue, newDefaultValue);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setDefaultValue(PreferenceDefaultValueAttribute newDefaultValue)
  {
    if (newDefaultValue != defaultValue)
    {
      NotificationChain msgs = null;
      if (defaultValue != null)
        msgs = ((InternalEObject)defaultValue).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - AndroGuiPackage.EDIT_TEXT_PREFERENCE__DEFAULT_VALUE, null, msgs);
      if (newDefaultValue != null)
        msgs = ((InternalEObject)newDefaultValue).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - AndroGuiPackage.EDIT_TEXT_PREFERENCE__DEFAULT_VALUE, null, msgs);
      msgs = basicSetDefaultValue(newDefaultValue, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, AndroGuiPackage.EDIT_TEXT_PREFERENCE__DEFAULT_VALUE, newDefaultValue, newDefaultValue));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case AndroGuiPackage.EDIT_TEXT_PREFERENCE__DIALOG_TITLE:
        return basicSetDialogTitle(null, msgs);
      case AndroGuiPackage.EDIT_TEXT_PREFERENCE__DEFAULT_VALUE:
        return basicSetDefaultValue(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case AndroGuiPackage.EDIT_TEXT_PREFERENCE__DIALOG_TITLE:
        return getDialogTitle();
      case AndroGuiPackage.EDIT_TEXT_PREFERENCE__DEFAULT_VALUE:
        return getDefaultValue();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case AndroGuiPackage.EDIT_TEXT_PREFERENCE__DIALOG_TITLE:
        setDialogTitle((PreferenceDialogTitleAttribute)newValue);
        return;
      case AndroGuiPackage.EDIT_TEXT_PREFERENCE__DEFAULT_VALUE:
        setDefaultValue((PreferenceDefaultValueAttribute)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case AndroGuiPackage.EDIT_TEXT_PREFERENCE__DIALOG_TITLE:
        setDialogTitle((PreferenceDialogTitleAttribute)null);
        return;
      case AndroGuiPackage.EDIT_TEXT_PREFERENCE__DEFAULT_VALUE:
        setDefaultValue((PreferenceDefaultValueAttribute)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case AndroGuiPackage.EDIT_TEXT_PREFERENCE__DIALOG_TITLE:
        return dialogTitle != null;
      case AndroGuiPackage.EDIT_TEXT_PREFERENCE__DEFAULT_VALUE:
        return defaultValue != null;
    }
    return super.eIsSet(featureID);
  }

} //EditTextPreferenceImpl
